/**
 * Created by DoveXL on 2018/12/22.
 */
$(document).ready(function () {
    $("#startdatepickerQuery").datepicker({
        autoclose: true,
        todayHighlight: true,
        language:"zh-CN"
    });
    $("#enddatepickerQuery").datepicker({
        autoclose: true,
        todayHighlight: true,
        language:"zh-CN"
    });
    $("#startdatepickerQuery1").datepicker({
        autoclose: true,
        todayHighlight: true,
        language:"zh-CN"
    });
    $("#enddatepickerQuery1").datepicker({
        autoclose: true,
        todayHighlight: true,
        language:"zh-CN"
    });
    VolunteerSignStatisticFunction();
    VolunteerRecordStatisticFunction();
    VolunteerSignStatisticsQueryData(null,null,null)
});



function VolunteerSignStatisticFunction(UserList,data1,data2) {
    var option = {
        tooltip : {
            trigger: 'axis',
            axisPointer : {            // 坐标轴指示器，坐标轴触发有效
                type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
            }
        },
        legend: {
            data: ['全天', '半天']
        },
        grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true
        },
        xAxis:  {
            type: 'value'
        },
        yAxis: {
            type: 'category',
            data: ['周一','周二','周三','周四','周五']
        },
        series: [
            {
                name: '直接访问',
                type: 'bar',
                stack: '总量',
                label: {
                    normal: {
                        show: true,
                        position: 'insideRight'
                    }
                },
                data: [320, 302, 301, 334, 390]
            },
            {
                name: '邮件营销',
                type: 'bar',
                stack: '总量',
                label: {
                    normal: {
                        show: true,
                        position: 'insideRight'
                    }
                },
                data: [120, 132, 101, 134, 90]
            }
        ]
    };
    var myChart = echarts.init(document.getElementById('main'));
    myChart.setOption(option);
    $(function () {
        $(window).resize(function(){
            myChart.resize($(window).width*0.75,$(window).height*0.75);
        });
    });

}



function VolunteerRecordStatisticFunction(UserList,data) {
    var option = {
        tooltip : {
            trigger: 'axis',
            axisPointer : {
                type : 'shadow'
            }
        },
        legend: {
            data: ['讲解次数']
        },
        grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true
        },
        xAxis:  {
            type: 'value'
        },
        yAxis: {
            type: 'category',
            data: ['周一','周二','周三','周四','周五']
        },
        series: [
            {
                name: '直接访问',
                type: 'bar',
                stack: '总量',
                label: {
                    normal: {
                        show: true,
                        position: 'insideRight'
                    }
                },
                data: [320, 302, 301, 334, 390]
            }
        ]
    };
    var myChart = echarts.init(document.getElementById('main1'));
    myChart.setOption(option);
    $(function () {
        $(window).resize(function(){
            myChart.resize($(window).width*0.75,$(window).height*0.75);
        });
    });

}



function VolunteerSignStatisticsQueryData(StartDate,EndDate,Unit) {
    $.ajax({
        async: true,
        type: "post",
        url: "/VolunteerPlatform/VolunteerSign/VolunteerSignStatistics",
        dataType: "json",
        contentType : 'application/json;charset=utf-8',
        data: JSON.stringify({"page":1,"pagesize":5,"StartDate":StartDate,"EndDate":EndDate,"Unit":Unit}),
        cache: false,
        success: function(data) {
            var result = eval(data);
            $("#TeamManagementInfo tr").empty();
            for (var i = 0; i<result.pagelist.length; i++) {
                var row = CreateTeamRow(result.pagelist[i]);
                $("#TeamManagementInfo").append(row);
            };
            var currentPage = result.currentpage; //当前页数
            var pageCount = result.pagecount; //总页数
            var options = {
                bootstrapMajorVersion: 3, //版本
                currentPage: currentPage, //当前页数
                totalPages: pageCount, //总页数
                numberOfPages: 8,
                shouldShowPage:true,//是否显示该按钮
                itemTexts: function (type, page, current) {
                    switch (type) {
                        case "first":
                            return "首页";
                        case "prev":
                            return "上一页";
                        case "next":
                            return "下一页";
                        case "last":
                            return "末页";
                        case "page":
                            return page;
                    }
                },
                onPageClicked: function (event, originalEvent, type, page) {
                    $.ajax({
                        async: true,
                        url: "/VolunteerPlatform/TeamInfo/CertainTeamInfo",
                        type: "post",
                        dataType : "json",
                        contentType : 'application/json;charset=utf-8',
                        data: JSON.stringify({"page":page,"pagesize":8,"TeamName":TeamName}),
                        cache: false,
                        success: function (data) {
                            $("#TeamManagementInfo tr").empty();
                            var result = eval(data);
                            for (var i = 0; i <result.pagelist.length; i++) {
                                var row = CreateTeamRow(result.pagelist[i]);
                                $("#TeamManagementInfo").append(row);
                            };
                        }
                    });
                }
            };
            $('#TeampageList').bootstrapPaginator(options);
        }
    });
}

